package com.lvy.hczn.front.business.controller;

import com.lvy.hczn.front.business.service.SpuGradeService;
import com.lvy.hczn.front.business.util.ResultUtil;
import com.lvy.hczn.front.common.core.controller.BaseController;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.front.system.domain.business.Spu;
import com.lvy.hczn.front.system.domain.business.SpuGrade;
import com.lvy.hczn.front.system.service.SpuService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/wcs/spu")
@RestController
@Slf4j
public class SpuController extends BaseController {

    @Autowired
    private SpuService spuService;

    @ApiOperation(value = "根据ID和温区查询", notes = "根据ID和温区查询")
    @PostMapping("/selectByIdAndTemperatureCode")
    public ResultUtil selectByIdAndTemperatureCode(@RequestBody Spu spu) {
        try {
            return ResultUtil.ok(spuService.selectByIdAndTemperatureCode(spu));
        } catch (Exception e) {
            log.error("selectList:{}", e);
            if (e instanceof UtilException) {
                return ResultUtil.failed(e.getMessage());
            } else {
                return ResultUtil.failed("系统异常");
            }
        }
    }
}
